﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.DigitalTwinAlignment.CApJsonConvertor
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using Newtonsoft.Json;


namespace DnProcessSimulateCommands.DigitalTwinAlignment;

public static class CApJsonConvertor
{
  private static readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings()
  {
    ReferenceLoopHandling = (ReferenceLoopHandling) 1
  };

  public static T ConvertFromJson<T>(string jsonData) where T : class
  {
    if (string.IsNullOrWhiteSpace(jsonData))
      return default (T);
    try
    {
      return JsonConvert.DeserializeObject<T>(jsonData, CApJsonConvertor._serializerSettings);
    }
    catch
    {
    }
    return default (T);
  }

  public static string ConvertToJson<T>(T obj) where T : class
  {
    return JsonConvert.SerializeObject((object) obj, CApJsonConvertor._serializerSettings);
  }
}
